package com.qf.kdgroup.gdbackend.controller;

import com.github.pagehelper.PageInfo;
import com.qf.kdgroup.gdbackend.dto.ResultBean;
import com.qf.kdgroup.gdbackend.entity.Auth;
import com.qf.kdgroup.gdbackend.service.AuthService;
import com.qf.kdgroup.gdbackend.vo.PageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/auth")
@CrossOrigin
public class AuthController {

    @Autowired
    private AuthService authService;

    @PostMapping("/getList")
    public PageInfo getList(@RequestBody PageVO pageVO){
        return authService.selectAllByPage(pageVO);
    }

    @DeleteMapping("/delete")
    public ResultBean deleteByAuthId(@RequestBody Auth auth){

        return authService.deleteByAuthId(auth.getAuthid());

    }

    @PostMapping("/add")
    public ResultBean add(@RequestBody Auth auth){

        return authService.add(auth);
    }

    @PostMapping("/find")
    public Auth findByAuthId(@RequestBody Auth auth){

        return authService.findByAuthId(auth.getAuthid());
    }

    @PostMapping("/update")
    public ResultBean update(@RequestBody Auth auth){

        return authService.update(auth);
    }
}
